﻿using System;

namespace MangaGrr.DomainModel
{
    [Serializable]
    public class Manga : IComparable
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string URL { get; set; }
        public MangaSite MangaSite { get; set; }
        public int TotalChapter { get; set; }

        #region IComparable Members

        public int CompareTo(object obj)
        {
            try
            {
                Manga manga = (Manga)obj;

                int i = System.String.CompareOrdinal(Name, manga.Name);

                if (i == 0) //same name
                    i = System.String.CompareOrdinal(MangaSite.Name, manga.MangaSite.Name);

                return i;
            }
            catch
            {
                return 0;
            }
        }

        #endregion
    }
}
